/*   1:    */ package com.rinsi.login;
/*   2:    */ 
/*   3:    */ import com.rinsi.core.CoreCache;
/*   4:    */ import com.rinsi.core.service.CoreService;
/*   5:    */ import com.rinsi.util.AssertUtil;
/*   6:    */ import com.rinsi.util.MapUtil;
/*   7:    */ import java.util.HashMap;
/*   8:    */ import java.util.List;
/*   9:    */ import java.util.Map;
/*  10:    */ import org.mybatis.spring.SqlSessionTemplate;
/*  11:    */ import org.springframework.stereotype.Service;
/*  12:    */ 
/*  13:    */ @Service
/*  14:    */ public class LoginService
/*  15:    */   extends CoreService
/*  16:    */ {
/*  17:    */   public Map<String, Object> login(Map<String, Object> model)
/*  18:    */   {
/*  19: 28 */     Map<String, Object> params = getParams(model);
/*  20:    */     
/*  21: 30 */     Map<String, Object> config = getConfig(model);
/*  22:    */     
/*  23: 32 */     Map<String, Object> rMap = null;
/*  24: 34 */     if (AssertUtil.isMapNotEmpty(params))
/*  25:    */     {
/*  26: 36 */       rMap = getRMap();
/*  27:    */       
/*  28: 38 */       Map<String, Object> user = (Map)getSqlSessionTemplate().selectOne(namespace(config) + ".getLoginUser", params);
/*  29: 40 */       if ((!AssertUtil.isMapNotEmpty(user)) || (!MapUtil.getString(user, "USER_PASSWORD").equals(MapUtil.getString(params, "USER_PASSWORD"))))
/*  30:    */       {
/*  31: 42 */         rMap.put("success", Boolean.valueOf(false));
/*  32:    */         
/*  33: 44 */         rMap.put("message", "用户不存在或账号密码有误！");
/*  34:    */         
/*  35: 46 */         return rMap;
/*  36:    */       }
/*  37: 50 */       if ("ZF".equals(MapUtil.getString(params, "USER_TYPE")))
/*  38:    */       {
/*  39: 52 */         if (("4".equals(MapUtil.getString(user, "ORGAN_TYPE"))) || ("5".equals(MapUtil.getString(user, "ORGAN_TYPE"))) || ("9".equals(MapUtil.getString(user, "ORGAN_TYPE"))))
/*  40:    */         {
/*  41: 54 */           rMap.put("success", Boolean.valueOf(false));
/*  42:    */           
/*  43: 56 */           rMap.put("message", "您是企业端用户、请在企业端登录！");
/*  44:    */           
/*  45: 58 */           return rMap;
/*  46:    */         }
/*  47:    */       }
/*  48: 64 */       else if (("1".equals(MapUtil.getString(user, "ORGAN_TYPE"))) || ("2".equals(MapUtil.getString(user, "ORGAN_TYPE"))) || ("3".equals(MapUtil.getString(user, "ORGAN_TYPE"))))
/*  49:    */       {
/*  50: 66 */         rMap.put("success", Boolean.valueOf(false));
/*  51:    */         
/*  52: 68 */         rMap.put("message", "您是政府端用户、请在政府端登录！");
/*  53:    */         
/*  54: 70 */         return rMap;
/*  55:    */       }
/*  56: 78 */       rMap.put("uid", MapUtil.getString(user, "USER_ID"));
/*  57:    */       
/*  58: 80 */       CoreCache.create(MapUtil.getString(user, "USER_ID"));
/*  59:    */       
/*  60: 82 */       CoreCache.cache(MapUtil.getString(user, "USER_ID"), "user", user);
/*  61:    */     }
/*  62: 86 */     return rMap == null ? new HashMap() : rMap;
/*  63:    */   }
/*  64:    */   
/*  65:    */   public Map<String, Object> load(Map<String, Object> model)
/*  66:    */   {
/*  67: 99 */     Map<String, Object> params = getParams(model);
/*  68:    */     
/*  69:101 */     Map<String, Object> config = getConfig(model);
/*  70:    */     
/*  71:103 */     Map<String, Object> rMap = getRMap();
/*  72:    */     
/*  73:105 */     String uid = MapUtil.getString(params, "uid");
/*  74:    */     
/*  75:107 */     Map<String, Object> user = CoreCache.getCacheMap(uid, "user");
/*  76:    */     
/*  77:109 */     Map<String, Object> role = (Map)getSqlSessionTemplate().selectOne(namespace(config) + ".getUserRole", user);
/*  78:    */     
/*  79:111 */     List<Map<String, Object>> modules = getSqlSessionTemplate().selectList(namespace(config) + ".getUserModules", user);
/*  80:    */     
/*  81:113 */     List<Map<String, Object>> organs = getSqlSessionTemplate().selectList(namespace(config) + ".getUserOrgans", user);
/*  82:    */     
/*  83:115 */     Map<String, Object> organ = (Map)getSqlSessionTemplate().selectOne(namespace(config) + ".getUserOrgan", user);
/*  84:    */     
/*  85:    */ 
/*  86:118 */     CoreCache.cache(MapUtil.getString(user, "USER_ID"), "roles", role);
/*  87:    */     
/*  88:120 */     CoreCache.cache(MapUtil.getString(user, "USER_ID"), "modules", modules);
/*  89:    */     
/*  90:122 */     CoreCache.cache(MapUtil.getString(user, "USER_ID"), "organs", organs);
/*  91:    */     
/*  92:124 */     CoreCache.cache(MapUtil.getString(user, "USER_ID"), "organ", organ);
/*  93:    */     
/*  94:126 */     rMap.put("user", CoreCache.getCacheMap(MapUtil.getString(user, "USER_ID"), "user"));
/*  95:    */     
/*  96:128 */     rMap.put("roles", CoreCache.getCacheMap(MapUtil.getString(user, "USER_ID"), "roles"));
/*  97:    */     
/*  98:130 */     rMap.put("modules", CoreCache.getCacheList(MapUtil.getString(user, "USER_ID"), "modules"));
/*  99:    */     
/* 100:132 */     rMap.put("organs", CoreCache.getCacheList(MapUtil.getString(user, "USER_ID"), "organs"));
/* 101:    */     
/* 102:134 */     rMap.put("organ", CoreCache.getCacheMap(MapUtil.getString(user, "USER_ID"), "organ"));
/* 103:    */     
/* 104:136 */     return rMap;
/* 105:    */   }
/* 106:    */   
/* 107:    */   public Map<String, Object> workinfo(Map<String, Object> model)
/* 108:    */   {
/* 109:142 */     Map<String, Object> params = getParams(model);
/* 110:    */     
/* 111:144 */     Map<String, Object> config = getConfig(model);
/* 112:    */     
/* 113:146 */     Map<String, Object> rMap = getRMap();
/* 114:    */     
/* 115:148 */     String uid = MapUtil.getString(params, "UID");
/* 116:    */     
/* 117:150 */     Map<String, Object> user = CoreCache.getCacheMap(uid, "user");
/* 118:    */     
/* 119:152 */     rMap.put("countWorks", (Map)getSqlSessionTemplate().selectOne(namespace(config) + ".countWorks", MapUtil.getString(user, "USER_ID")));
/* 120:    */     
/* 121:154 */     rMap.put("user", user);
/* 122:    */     
/* 123:156 */     return rMap;
/* 124:    */   }
/* 125:    */ }


/* Location:           D:\Users\Desktop\shanxi\项目\sxazmis\WEB-INF\classes\
 * Qualified Name:     com.rinsi.login.LoginService
 * JD-Core Version:    0.7.0.1
 */